/*
 * Copyright (c) 2001, 2002 Boris Pruessmann and others. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Common Public License v0.5 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: Boris Pruessmann - Initial implementation (for other commands).
 * David Corbin - initial implementation of this command.
 */
package net.sourceforge.perforce.core.internal.api;

import net.sourceforge.perforce.api.IError;
import net.sourceforge.perforce.api.IPerforceCommand;
import net.sourceforge.perforce.core.PerforceCorePlugin;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;

import java.util.Map;

/**
 * ClientUser object for the 'p4 change' command.
 * 
 * @version $Revision: 488 $
 * @author <a href="mailto:bpruessmann@users.sourceforge.net">Boris
 *         Pruessmann</a>
 * @author <a href="mailto:dcorbin@users.sourceforge.net">David Corbin</a>
 */
public class SimpleCmd extends AbstractPerforceCommand implements IPerforceCommand {
  // ---------------------------------------------------------------------------
  // Private Variables

  /** Stores the name of the command. */
  private String cmdName;

  // --------------------------------------------------------------- Public
  // Static Factory Methods

  /**
   * Convenience method for creating instances of Change.
   * 
   * @param cmdName the name of the perforce command.
   * @return the new instance of SimpleCmd.
   */
  public static final SimpleCmd newInstance(String cmdName) {
    MultiStatus status = new MultiStatus(PerforceCorePlugin.ID, IStatus.OK, "", null);
    return new SimpleCmd(status, cmdName);
  }

  // ------------------------------------------------------------------------
  // Private Constructors

  /**
   * Constructor for SimpleCmd.
   * 
   * @param status the MultiStatus object.
   * @param cmdName the name of the command.
   */
  private SimpleCmd(MultiStatus status, String cmdName) {
    super(status);
    this.cmdName = cmdName;
  }

  // -------------------------------------------------------- Public Methods
  // (IClientUserDelegate)

  @Override
  public String inputData(IError error) {
    return "";
  }

  // ----------------------------------------------------------- Public Methods
  // (IPerforceCommand)

  public String getCommand() {
    return cmdName;
  }

  @Override
  public void outputStat(Map<String, ?> strDict) {
    // override outputStat to avoid UnsupportedOperationExceptions.
    System.out.println(strDict);
  }

  @Override
  public IStatus getStatus() {
    return getMultiStatus();
  }
}
